package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Vote;
import cn.wolfcode.mapper.VoteMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IVoteService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VoteServiceImpl implements IVoteService {

    @Autowired
    private VoteMapper voteMapper;


    @Override
    public void save(Vote vote) {

    }

    @Override
    public void delete(Long id) {

    }

    @Override
    public void update(Vote vote) {

    }

    @Override
    public Vote get(Long id) {
        return voteMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Vote> listAll() {
        return voteMapper.selectAll();
    }

    @Override
    public PageInfo<Vote> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize()); //对下一句sql进行自动分页
        List<Vote> votes = voteMapper.selectForList(qo); //里面不需要自己写limit
        return new PageInfo<Vote>(votes);
    }

    @Override
    public void inputVoteEmployee(Long voteId, Long id, Long ovteItemId) {
        voteMapper.inputVoteEmployee(voteId,id,ovteItemId);
    }

    @Override
    public List<Vote> countVoteEmployee(Long voteId) {
        List<Vote> i = voteMapper.countVoteEmployee(voteId);
        return i;
    }

    @Override
    public List<Vote> check(Long employeeId) {
        List<Vote> check = voteMapper.check(employeeId);
        return check;
    }
}
